{include file="public/head" /}
<div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">商城管理</a>
            <a>
              <cite>商品管理</cite></a>
          </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="../shop/goods" title="刷新">
        <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
</div>
<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                    </form>
                </div>
                <div class="layui-card-body ">
                    <table class="layui-hide" id="test" lay-filter='test1'></table>
                </div>
                <div class="layui-card-body ">
                    <div class="page" id="page"></div>
                </div>
            </div>
        </div>
    </div>
    <input type="hidden" id="ids" value="">
</div>
</body>
<script>
    layui.use(['laydate', 'form', 'laypage','table'], function(){
        var table = layui.table;
        var laydate = layui.laydate;
        console.log(laydate);
        table.render({
            elem: '#test'  //绑定table id
            ,url:'/marketing/cs'  //数据请求路径
            ,cellMinWidth: 80
            ,cols: [[
                {type:'numbers'}
                ,{field:'id', title:'菜单名称'}
                ,{field:'name', title:'父菜单名称',width:150}
                ,{field:'store_ids', title: '菜单路径'}
                ,{fixed: 'right',title: '操作', width:180,      align:'center', toolbar: '#toolBar'}//一个工具栏  具体请查看layui官网
            ]]
            ,page: true   //开启分页
            ,limit:10   //默认十条数据一页
            ,limits:[10,20,30,50]  //数据分页条
            ,id: 'testReload'
        });




        var laypage = layui.laypage;
        var form = layui.form;
        var url = '{:url("../shop/order")}'+'?{$query}';

        form.on('checkbox(allChoose)', function (data) {
            var child = $(".seach-box input[type='checkbox']");
            var check_arr = [];
            var str = '';
            child.each(function (index, item) {
                item.checked = data.elem.checked;
                check_arr.push($(this).val());
            });
            for(var i=0; i<check_arr.length; i++)
            {
                if(check_arr.length == (i+1))
                {
                    str += check_arr[i];
                }
                else
                {
                    str += check_arr[i] + ',';
                }
            }
            $('#ids').val(str); //赋值给隐藏表单
            console.log("选中的", str)
            form.render('checkbox');
        });
        //执行一个laydate实例
        laydate.render({
            elem: '#start1' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end1' //指定元素
        });
        //执行一个laypage实例
        laypage.render({
            elem: 'page' //注意，这里的 test1 是 ID，不用加 # 号
            ,count:'{$count}'//数据总数，从服务端得到
            ,limit :'{$pageTotal}'
            ,curr:'{$curr}'
            ,jump: function(obj, first){
                if(!first){ //一定要加此判断，否则初始时会无限刷新
                    location.href = url+'&page='+obj.curr;
                }
            }
        });
    });

    /*用户-停用*/
    function member_stop(obj,id){
        var str = '';
        var status = $('#'+id+'_s').val();
        console.log(status);
        if(status == 2)
        {
            str = '确认要停用吗？';
        }
        else
        {
            str = '确认要启用吗？';
        }
    }

    /*用户-删除*/
    function member_del(obj,id){
        layer.confirm('确认要核销吗？',function(index){
            $.ajax({
                type: "POST",
                url: "{:getUrl()}shop/orderWrite",
                data: {id:id},
                dataType: "json",
                success: function(data){
                    if(data.code > 0)
                    {
                        layer.msg('核销成功!',{icon:1,time:1000});
                        window.parent.location.reload();
                    }
                    else
                    {
                        layer.msg(data.msg,{icon: 5,time:1000});
                    }
                }
            });
        });
    }

</script>
</html>